package com.intmall.train.${module}.controller;

import com.intmall.train.common.context.LoginMemberContext;
import com.intmall.train.common.domain.resp.CommonPageResp;
import com.intmall.train.common.domain.resp.CommonResp;
import com.intmall.train.${module}.domain.req.${Domain}QueryReq;
import com.intmall.train.${module}.domain.req.${Domain}SaveReq;
import com.intmall.train.${module}.domain.resp.${Domain}QueryResp;
import com.intmall.train.${module}.service.${Domain}Service;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/${domain}")
public class ${Domain}Controller {
    @Resource
    private ${Domain}Service ${domain}Service;

    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody ${Domain}SaveReq req) {
        ${domain}Service.save(req);
        return new CommonResp<>();
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        ${domain}Service.delete(id);
        return new CommonResp<>();
    }

    @PostMapping("/queryList")
    public CommonPageResp<${Domain}QueryResp> queryList(@RequestBody ${Domain}QueryReq req) {
        req.setMemberId(LoginMemberContext.getId());
        return ${domain}Service.queryList(req);
    }
}
